Part Number Hot Search : 
101MC Y7C10 L3208AC G0512 08163224 E200A MC145109 D2010
Product Description
Full Text Search
 

To Download AN986 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  AN986/1098 1/6 application note using the indirect addressing mode with st7 by 8-bit micro application team introduction the st7 assembly language instruction set includes the indirect addressing mode (indexed or not) for short and long variables. the purpose of this document is to show how using the indi- rect addressing mode is useful. 1 description of the indirect addressing modes as it is shown in the following examples, the indirect addressing mode is used by the assembly language when the destination byte is inside brackets [ ]. in this mode the label located inside the brackets is called a pointer. in the st7 instructions set the pointer must be located in the short addressing ram: its address must be a byte. 1.1 short indirect addressing mode the pointer contains the address of the data to process. this mode allows the result of a pre- vious calculation to be the address of the data to process. n addressable space: $00 to $ff. n example: if the pointer label is an 8 bit symbol defined as $9b. before completion address data 4d 85 $85 address data d4 85 $85 label:$9b after completion swap [label] label:$9b 1
2/6 using the indirect addressing mode with st7 1.2 long indirect addressing mode this mode is similar to the short indirect mode, but the effective address is a 16-bit word. this allows to access the whole address range. n addressable space: $0000 to $ffff. n example: if the pointer label is an 8 bit symbol defined as $9b. note the extension a.wo indicates the long indirect addressing mode is used. 1.3 short indirect indexed addressing mode in this mode, as the short indirect mode, the byte address following the opcode contains an 8- bit pointer. the pointer content is added with the content of an index register (x or y). the sum is the effective address of the data to process. n addressable space: $000 to $1fe. n example: if the pointer label is an 8 bit symbol defined as $85 and if x register contains 4. before completion address data d4 20 $9c label:$9b after completion ld a,[label.w] e5 $e5d4 a= $20 before completion address data fe 0a label:$85 $fe after completion clr ([label],x) $ff $100 $101 $102 1e f6 a8 b3 address data fe 0a label:$85 $fe $ff $100 $101 $102 1e f6 a8 00 $fe+$04=$102 with x=4
3/6 using the indirect addressing mode with st7 1.4 long indirect indexed addressing mode this mode uses a 16-bit index in the memory and adds its contents with the 8-bit content of the index register (x or y), the sum is the effective 16-bit address of the data to process. addressable space: $0000 to $ffff. example: if the pointer label is an 8 bit symbol defined as $85 and if x register contains 2. note the a .w o indicates the long indirect addressing mode is used. 2 advantages in assembly language programmation this addressing mode allows to minimize an application size code. instead of using a macro to define a repetitive operation with different parameters, the indirect addressing mode per- mits to use a function. 2.1 example the purpose of the following example is to write a part of code which increments all the values contained in an array. this code must be reusable in the same program to process different arrays. the first address and the array length are given. before completion address data 4d 0a $86 $e14d after completion ld a,([label.w],x) $e14f $e150 1e f6 $e14d+$02=$e150 e1 label:$85 a=$f6 with x=4
4/6 using the indirect addressing mode with st7 2.1.1 using a macro and direct addressing mode. this macro use direct indexed addressing mode. inc_arr macro array, lgth;array is the address of the first byte of ;the array, lght contains the array length local jump ld x,#{lgth-1} jump inc (array,x),a ;direct indexed addressing mode ld dec x jrpl jump mend 2.1.2 using a function and indirect instructions the function uses the indirect indexed mode. .fct_inc ld ad_array,a ;ad_array contains the array address,this ;parameter is stored in a, the length in x .cont inc ([ad_array],x)) ;indirect indexed addressing mode dec x jrpl cont ret in this example the incremented array (array1) is defined in the short addressing ram, array1 is the starting address and lght1 the length. the function afct_inco is called by the program as it shown in the following lines follow. ld a,#array1 ;the array1 address is stored in a ld x,#{lght1-1} call fct_inc 2.2 conclusion every time the macro is used the code is copied in rom, when using a function the code is written only one time and the data are processed using the indirect addressing mode. this example shows that only the indirect addressing mode allow to use of a function in this case, thus an optimization in term of application size code using the assembly language.
5/6 using the indirect addressing mode with st7 3 advantages in c language programmation in many programming applications, the data may have complex forms. to ease the handling of these data, c language is used that simplify the writing of the code by allowing expressions like: ac[k] = ab[j] + aa[i]; where aa, ab and ac are arrays of numbers, and i, j and k the indexes to these arrays. the hiware c compiler for st7 translates this in available machine-language instructions in- cluded in the st7 instruction set. if these are arrays of bytes which base address is ram but not in page zero, the following in- struction sequence would fit: ld x, j ; set index register to value of index i of ;array aa ld a,([ab.w],x) ; get value aa[i] / indirect addressing mode ld x, i ; set index register to value of index j of ;array ab add a,([aa.w],x) ; add value of ab[j]/ indirect addressing mode ld x, k ; set index register to value of index k of ;array ac ld ([ac.w],x),a ; put result into ac[k] in this case, the whole addition is performed in: -31cycles - 3.875 m satf cpu =8mhz - 15 bytes of code. if the 3 arrays are located in the page zero (address on 8 bits), the whole addition is performed in: -28cycles - 3.5 m satf cpu =8mhz - 15 bytes of code. the obvious compacted size of this generated code is due to the indirect addressing mode in the st7 instruction set. this is only one of the many examples where powerful addressing modes help translate high- level language with a good efficiency.
6/6 using the indirect addressing mode with st7 the present note which is for guidance only aims at providing customers with information regarding their products in order for them to save time. as a result, stmicroelectronics shall not be held liable for any direct, indirect or consequential damages with respect to any claims arising from the content of such a note and/or the use made by customers of the information contained herein in connexion with their products. information furnished is believed to be accurate and reliable. however, stmicroelectronics assumes no responsibility for the consequences of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. n o license is granted by implication or otherwise under any patent or patent rights of stmicroelectronics. specifications mentioned in this publication are subject to change without notice. this publication supersedes and replaces all information previously supplied. stmicroelectronics products are not authorized for use as critical components in life support devices or systems without the express written approval of stmicroelectronics. the st logo is a registered trademark of stmicroelectronics ? 1998 stmicroelectronics - all rights reserved. purchase of i 2 c components by stmicroelectronics conveys a license under the philips i 2 c patent. rights to use these components in an i 2 c system is granted provided that the system conforms to the i 2 c standard specification as defined by philips. stmicroelectronics group of companies australia - brazil - canada - china - france - germany - italy - japan - korea - malaysia - malta - mexico - morocco - the netherlands - singapore - spain - sweden - switzerland - taiwan - thailand - united kingdom - u.s.a. http:/ /www.st.com hiware is registered trademarks of hiware ag,


▲Up To Search▲   

 
Price & Availability of AN986

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X